package com.yinhd.study.CompletableFutureStudy;

import java.util.concurrent.CompletableFuture;

/**
 * @program: study
 * @description:
 * @Author: yinhd
 * @create: 2022-01-18 11:15
 **/
public class supplyAsync_01 {
    public static void main(String[] args) {
        SmallTool.printTimeAndThread("进入餐厅点餐");
        CompletableFuture<String> stringCompletableFuture = CompletableFuture.supplyAsync(() -> {
            SmallTool.sleepMillis(200L);
            SmallTool.printTimeAndThread("炒菜");
            SmallTool.sleepMillis(100L);
            SmallTool.printTimeAndThread("盛饭");
            return "饭做好了";
        });
        SmallTool.printTimeAndThread("打王者");
        SmallTool.printTimeAndThread(String.format("%s,小白开吃",stringCompletableFuture.join()));
    }
}
